package com.dmooo.ymx.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.dmooo.ymx.R;
import com.dmooo.ymx.mallbean.MallCatbean;

import java.util.List;

public class MyGridViewAdapter extends BaseAdapter {
    Context context;
    List<MallCatbean> list;

    private LayoutInflater mInflater;

    public MyGridViewAdapter(Context _context, List<MallCatbean> _list) {
        this.list = _list;
        this.context = _context;
        mInflater=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);//LayoutInflater.from(mContext);
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if(convertView==null){
            holder = new ViewHolder();
            convertView = mInflater.inflate(R.layout.activity_myshop_horlistview, null);
            holder.mTitle=(TextView)convertView.findViewById(R.id.text_list_item);
            convertView.setTag(holder);
        }else{
            holder=(ViewHolder)convertView.getTag();
        }

        holder.mTitle.setText(list.get(position).getCat_name());
        return convertView;
    }
    private static class ViewHolder {
        private TextView mTitle ;
    }
}
